package descentFly.app.sight
{
	import UIFree.controls.uif_label;
	import UIFree.uif_component;
	
	import descentFly.app.df_component;
	
	import flash.geom.Matrix;
	import flash.geom.Point;
	
	public class df_ring extends df_component {
		private var _radius		: Number;
		private var _destText	: uif_label;
		public function df_ring(parent:uif_component, a_radius: Number, styleClass:Object='') {
			_radius = a_radius;
			super(parent, 0, 0, a_radius, a_radius, styleClass);
			_destText = new uif_label(this, -40, -a_radius, 80, 20, style.label);
		}
		
		public function set destanceLabel(a_text: String): void {
			_destText.text = a_text + 'dm';
		}
		
		override protected function defaultDrawMethod(): String {
			return 'drawRing';
		}
		
		public function drawRing(x:int, y:int, width:int, height:int, style:Object): void {
			begin2(style);
			var num: int = 18;
			//			graphics.lineStyle(1, 0xFF0000);
			graphics.drawCircle(0, 0, _radius);
			
			var mat: Matrix = new Matrix();
			var step: Number = 1 / num * Math.PI * 2
			for (var i: int=0; i<num; i++) {
				var p1: Point = new Point(_radius * 0.95, 0);
				var p2: Point = new Point(_radius, 0);
				mat.rotate(step);
				p1 = mat.transformPoint(p1);
				p2 = mat.transformPoint(p2);
				graphics.moveTo(p1.x, p1.y);
				graphics.lineTo(p2.x, p2.y);
			}
		}
	}
}